import React, { useEffect } from 'react';
import {
  ResourceManager,
  columnFieldsMap,
  ResourceManagerProps,
  container,
  pipes,
} from 'easyComponent';

import { commonData } from './commonData';

pipes.forEach(item => container.addPipe(item.name, item));
// console.log(pipes, 'xxxvdsd');

export default () => {
  const config: ResourceManagerProps = {
    componentsMap: columnFieldsMap,
    rowKey: 'id',
    title: '电脑价格',
    fields: [
      {
        label: '型号',
        name: 'name',
        componentName: 'TextColumnField',
      },
      {
        label: '价格',
        name: 'price',
        componentName: 'TextColumnField',
        pipes: [{ name: 'numberPipe', options: { format: '0,0' } }],
      },
    ],
  };

  useEffect(() => {
    const a = [{ name: 'numberPipe', options: { format: '0,0' } }];
    // a.reduce((cur: any, next) => {
    //   console.log(cur, next, 'hahhah');
    // }, 555);
  });

  return (
    <div>
      <ResourceManager {...config} dataSource={commonData.pipeDemoData} />
    </div>
  );
};
